require(['jquery','../modules/pageSize','../modules/popup', 'Bswiper'],function($,pageSetSize,popup,aswiper){
	//设置html根目录字体大小
	setRootFontSize(pageSetSize);
	//图片滑动
	var aswiper = new Swiper('.swiper-container', {
        autoplay: 5000,
        pagination:'.swiper-pagination',
        paginationClickable: true
    });
    var isAjax =  false;
    // 首页关注店铺功能
    if($('.weixin-attention').hasClass('active')){
        $('.weixin-attention').text('关注')
    }
    else{
        $('.weixin-attention').text('取消')
    }    
    $('.weixin-attention').on('click', function(e){
        e.preventDefault();
        var localId = $(this).attr('data-localId');
        var _type;
        if($(this).text() == '关注'){
           _type = 'y';
        }else{
           _type = 'n';
        }
        _global.checkPhoner.verifyfunc = function(rs){
            if(rs){
                ajaxAttention(_type, localId);
                return true;
            }else{
                return false;
            }
        };
        _global.checkPhoner.succfunc = function(){
            ajaxAttention(_type, localId);
        };
        _global.checkPhoner.run(e);
    });
    function ajaxAttention(type, localId) {
        if (isAjax) return;
		isAjax = true;
        var $code = $(".shop-attention-name span font").text();
        var $number = '';
        if (type == "y") {
            $number = parseInt($code) + 1;
        } else {
            $number = parseInt($code) - 1;
        }        
        $.ajax({
            type: "get",
            url: "/Home/Member/storeCollect"+getFixedExtraUrl(),
            data: {'type': type, 'local_id': localId},
            dataType: "json",
            success: function (rs) {                
                popup.alertPopup(rs.msg);
                $('.weixin-attention').toggleClass('active');
                $(".shop-attention-name span font").html($number);
                if (type == "y") {
                    $('.weixin-attention').text('取消');
                }
                else {
                    $('.weixin-attention').text('关注');
                }
				isAjax = false;
            },
            error: function () {
                popup.alertPopup('服务器异常,请稍后重试！');
				isAjax = false;
            }
        });
    }

});




